package org.game.module.scene.Avatar
{
	import com.greensock.TweenMax;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	
	import org.game.common.Resourse.GameLoader;
	
	
	/**
	 * @author 缺硒
	 */
	public class CellAvatar extends Sprite
	{
		private static var __color:uint = 0x91e600;
		private var _id:String = "";
		private var _playFrame:int = 1;
		private var _size:int = 10;

		public function CellAvatar()
		{
//			var loader:GameLoader = new GameLoader();
//			loader.loadElement("assets/cell/a.png", onComplete);
			drawShape();
		}
		
		private function drawShape():void
		{
			graphics.beginFill(__color);
			graphics.drawCircle(0,0, _size);
			graphics.endFill();
			doAnimation();
		}
		
		private function doAnimation():void
		{
			if(_playFrame == 1)
			{
				TweenMax.to(this, 1, {glowFilter:{color:__color, alpha:1, blurX:_size + 10, blurY:_size + 10, strength:10}, onComplete:doAnimation});
				_playFrame = 2;
			}
			else
			{
				TweenMax.to(this, 1, {glowFilter:{color:__color, alpha:1, blurX:10, blurY:10, strength:10}, onComplete:doAnimation});
				_playFrame = 1;
			}
		}
		
		private function onComplete(loader:GameLoader):void
		{
			loader.content.x -= loader.content.width/2;
			loader.content.y -= loader.content.height/2;
			addChild(loader.content);
//			bitmapData =  Bitmap(loader.content).bitmapData;
		}

		public function get size():int
		{
			return _size;
		}

		public function set size(value:int):void
		{
			_size = value;
			drawShape();
		}

	}
	//
}